package org.cy.spring.learning.proxy.jdk.dynamic;

import lombok.extern.slf4j.Slf4j;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * create date: 2019/10/18 14:14
 *
 * @author cao.yong
 */
@Slf4j
public class DynamicInvocationHandler implements InvocationHandler {

    private Object target;

    DynamicInvocationHandler(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        log.info("JDK 动态代理 {}", proxy.getClass());
        return method.invoke(target, args);
    }
}
